<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>牧心农业</title>
    <link rel="stylesheet" type="text/css" href="/static/css/eui.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/mobile.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/iconfont.css" />
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/doT.min.js"></script>
    <script src="/static/js/func.js"></script>
</head>
<body>
    <div class="content margin_top">
        <header class="header fixed_top bg_mx_green"></header>
        <form class="vaccine"></form>
    </div>
    <div class="toast"></div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='info_template'>
        <div class="bg_white margin_b_10">
            <div class="padding_10_15 v_center border_b">
                <div class="width_50">日期</div>
                <div class="left_50">
                    <input class="padding_v_5" type="date" name="createtime" value="{{=it}}" request title="日期">
                </div>
            </div>
            <div class="padding_10_15 v_center border_b">
                <div class="width_50">价格</div>
                <div class="left_50">
                    <input type="text" name="price" placeholder="价格" request title="价格" data-pattern="^[0-9]+(.[0-9]{1,2})?$" data-tips="最多两位小数的数字">
                </div>
            </div>

            <div class="padding_10_15">
                <textarea name="remark" rows="5" placeholder="请输入疫苗情况描述" request title="疫苗情况描述"></textarea>
            </div>
        </div>
        <div class="padding_15 font_16">
            <button class="btn btn_mx_green all_width lineheight_3">保存</button>
        </div>
        <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
        <input type="hidden" name="pigid">
    </script>
    <script type="text/template" charset="utf-8" id='img_template'></script>
    <script>
        // 页面初始化
            var evalinfo = doT.template($("#info_template").text());
            var evalToast = doT.template($("#toast_template").text());
            var date_now = new Date();
            var d = date_now.getFullYear()+'-'+f(date_now.getMonth()+1)+'-'+f(date_now.getDate());
            loaddata(".vaccine",evalinfo,d);
            loadheadbar("添加疫苗情况",1)
        // 提交表单
            var submited = false;
            $(".vaccine").submit(function(e){
                e.preventDefault();
                var pigid = GetQueryString("pigid");
                $("input[name=pigid]").val(pigid)
                with(this){
                    for (var i = 0; i < this.length; i++) {
                        if($(this[i]).attr("request")==""){
                            if(!checkone(this[i])){
                                return false;
                            }
                        }
                    }
                    if(submited) return false;
                    var data = $(".vaccine").serialize();
                    $.post("/business/person/post-vaccine",data,function(res){console.log(res)
                        submited = true;
                        toast("attention",res.msg);
                        if(res.status == 0){
                            location.href='/business/person/pig';
                        }
                    },"json")
                }
            })
    </script>
</body>
</html>
